package com.freewater.parking.domain.common;

import org.apache.commons.lang3.Validate;

import java.util.Objects;

/**
 * 车牌号
 */
public final class PlateNumber implements ValueObject {

    private final String value;

    public PlateNumber(String value) {
        Validate.notBlank(value, "车牌号不能为空");
        this.value = value.trim();
    }

    public static PlateNumber of(String value) {
        return new PlateNumber(value);
    }

    /**
     * 返回车牌号
     *
     * @return 车牌号
     */
    public String getValue() {
        return value;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        PlateNumber that = (PlateNumber) o;
        return Objects.equals(value, that.value);
    }

    @Override
    public int hashCode() {
        return Objects.hash(value);
    }

    @Override
    public String toString() {
        return "PlateNumber{" +
                "value='" + value + '\'' +
                '}';
    }
}
